<?php
/**
 * 制作:  叶风
 * Qq:    355007778
 * Email: ye.fn@163.com
 *
 */
define('UNIX_TIME', time());
define('PROCESSOR_DIR', dirname(dirname(__FILE__)). DIRECTORY_SEPARATOR);
define('PLUG_DIR', PROCESSOR_DIR . 'plug'. DIRECTORY_SEPARATOR);
require PROCESSOR_DIR . 'lib/function.php';
require PROCESSOR_DIR . 'lib/framework.php';
require PROCESSOR_DIR . 'lib/log.php';
require PROCESSOR_DIR . 'lib/encrypt.php';
require PROCESSOR_DIR . 'lib/lang.php';
require PROCESSOR_DIR . 'lib/out.php';
require PROCESSOR_DIR . 'lib/control.php';
require PROCESSOR_DIR . 'lib/html.php';
require PROCESSOR_DIR . 'lib/url.php';

// load config
$domain = require PROCESSOR_DIR . 'config/domain.php';
$name = $_SERVER['HTTP_HOST'];
$domain = isset($domain[$name]) ? $domain[$name] : $domain['default'];

define('CONFIG_DIR', PROCESSOR_DIR . 'config/'. $domain['db'] . DIRECTORY_SEPARATOR);
define('CACHE_DIR',  PROCESSOR_DIR . 'cache/'. $domain['db'] . DIRECTORY_SEPARATOR);
define('BACKUP_DIR', dirname(PROCESSOR_DIR) . '/backup/' . $domain['db'] . DIRECTORY_SEPARATOR);
define('FILE_DIR',   dirname(PROCESSOR_DIR) . DIRECTORY_SEPARATOR . $domain['file_dir']);


$domain['time_zone'] && ini_set('date.timezone', $domain['time_zone']);

$config = require CONFIG_DIR . 'site.php';
$config = array_merge($config, $domain);
YF_f::$config = & $config;


// debug 0系统默认， -1关闭，2输出 
$_d = YF_f::get_cookie('YFdebug');
if ($_d!='')
	YF_f::$config['debug'] = $_d;
if (YF_f::$config['debug']>0)
 {
	ini_set("display_errors", "On");
	YF_f::$config['debug'] >3 && error_reporting(E_ALL);
 }
elseif (YF_f::$config['debug']<0)
 {
	ini_set("display_errors", "Off");
 }
 
// session
YF_f::$config['session_db']==1 ? YF_f::initC('session') : session_start();
    
//加载语言
lang::$dir = PROCESSOR_DIR . 'language/'. $config['language'] . DIRECTORY_SEPARATOR;
lang::load('common');

// init
define('TEMPLATE_DIR_A', WEB_DIR . 'theme/' .$config['a_template']  .DIRECTORY_SEPARATOR);
define('TEMPLATE_DIR_F', WEB_DIR . 'theme/'  . $config['f_template']  . DIRECTORY_SEPARATOR);
define('STYLE_PATH_A', 'theme/' .$config['a_template']  .'/' . $config['a_style'] . '/' );
define('STYLE_PATH_F', 'theme/' . $config['f_template']  .'/' . $config['f_style'] . '/' );
define('JS_PATH',    'js/');
$_ = dirname($_SERVER['PHP_SELF']);
$_=='/' or $_ .= '/';
define('ROOT_URL', $config['url'] ? $config['url'] : 'http://'. $_SERVER['HTTP_HOST'] . $_);

// un set 
unset($domain, $config, $name, $_d);
?>